<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /**
     * arr.splice(删除数组元素的索引位置，被删除的元素的个数,新添加的元素);
     * 从指定的索引位置 删除指定个数的数组元素arr.splice(index,num)
     * arr.splice(index,0,"新元素")
     * 在指定索引位置 添加新的元素
     * 前两个元素是必须参数 后面参数可选
     * 返回值是被删除元素组成的新数组
     */
    var userList=["zhangsan","lisi","liuxiangyu","wangwu","zhaoliu"];
    var index=userList.indexOf("liuxiangyu");
    var result=userList.splice(index,2);
    console.log(result);
    userList.splice(1,0,"liuneng","test");
    console.log(userList);
</script>
</html>